package com.zhudi.utils;

import java.math.BigDecimal;

/**
 * @author chenjc
 * @since 2021/02/25 15:31
 */
public class MathUtil {

    public static final BigDecimal MAX = new BigDecimal("999999");

    public static final BigDecimal TWO = new BigDecimal("2");


    /**
     * 求自然对数
     */
    public static BigDecimal getLn(BigDecimal number) {
        if (number.compareTo(BigDecimal.ZERO) == 0) {
            return BigDecimal.ZERO;
        }
        Double sqrt = Math.log(number.doubleValue());
        return BigDecimal.valueOf(sqrt);
    }

    /**
     * 开方
     */
    public static BigDecimal getSqrt(BigDecimal number) {
        Double sqrt = Math.sqrt(number.doubleValue());
        return BigDecimal.valueOf(sqrt);
    }
}
